#include "rclcpp/rclcpp.hpp"
#include "custom_srv_msg/srv/custom_srv.hpp"
#include "std_msgs/msg/string.hpp"

void srv_cb(const std::shared_ptr<custom_srv_msg::srv::CustomSrv::Request> req,
            std::shared_ptr<custom_srv_msg::srv::CustomSrv::Response> res)
{
    auto message = std_msgs::msg::String();
    auto message1 = std_msgs::msg::String();
    message.data = req->client;
    res->service = message.data + "   test";
    RCLCPP_INFO(rclcpp::get_logger("rclcpp"),message.data.c_str());
}

int main(int argc, char const *argv[])
{
    rclcpp::init(argc,argv);

    // rclcpp::spin(std::make_shared<ns_service_srv::service_srv>());
    std::shared_ptr<rclcpp::Node>node = rclcpp::Node::make_shared("service_node");
    rclcpp::Service<custom_srv_msg::srv::CustomSrv>::SharedPtr service_ptr =        //必须接收保存 create_service 返回值
    node->create_service<custom_srv_msg::srv::CustomSrv>("service_cli_demo",&srv_cb);
    RCLCPP_INFO(rclcpp::get_logger("rclcpp"), "server Ready");
    rclcpp::spin(node);
    rclcpp::shutdown();
    return 0;
}
